package day02;

/*
 * Author: JacksonCoder
 * FileName: demo2TypeChange
 * Version: 1.0.0
 * Date: 2025/3/31
 */

public class demo2TypeChange {

    public static void main(String[] args) {

        // 字符串转换为数组
        String ageStr = "23";
        int age = Integer.parseInt(ageStr); // 字符串转int
        Integer ageObj = Integer.valueOf(ageStr);

        System.out.println("ageStr = " + ageStr);
        System.out.println("age = " + age);
        System.out.println("ageObj = " + ageObj);

        // 数值转化为字符串
        double price = 99.99;
        String priceStr = Double.toString(price);

        System.out.println("price = " + price);
        System.out.println("priceStr = " + priceStr);

        // 进制转化
        String binary = Integer.toBinaryString(10);//十进制  -> 二进制 “1010”
        String hex = Integer.toHexString(255);  // 十进制 -> 十六进制  "ff"

        System.out.println("binary = " + binary);
        System.out.println("hex = " + hex);

    }

}
